"""
    客户端发送学生信息
"""

from socket import *
from struct import *


# 定义发送的数据格式
st = Struct("i32sif")

s = socket(AF_INET, SOCK_DGRAM)

while True:
    print("===========")
    id = int(input("输入ID: "))
    name = input("输入姓名: ")
    age = int(input("输入年龄: "))
    score = float(input("输入成绩: "))
    
    # 打包数据
    data = st.pack(id, name.encode(), age, score)
    s.sendto(data, ("127.0.0.1", 18693))
    
    data, addr = s.recvfrom(1024)
    print(data.decode())
    
    
    